package com.cwf.security.handle;

import com.cwf.security.utils.ResponseUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @description: 认证失败处理
 * @return:
 * @author 18068
 * @date: 2022/9/25 21:20
 */
@Component
public class AuthenticationEntryPointImp implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {

        Map<String,Object> res = new HashMap<>();
        res.put("code",403);
        res.put("msg","账号/密码错误");

        ResponseUtil.send(response,res);


    }
}
